
import { _decorator, assetManager, CCInteger, Component, Label, math, Node, ProgressBar, resources, Size, size, UITransform, Vec2, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

// 定义奖品区域枚举
enum EPrizeArea {
    WHEEL_ITEM_FREE = 1,   //謝謝參與
    WHEEL_ITEM_1 = 2,  //一等獎
    WHEEL_ITEM_2 = 3,  //二等獎
    WHEEL_ITEM_3 = 4,  //三等獎
    WHEEL_ITEM_4 = 5,  //四等獎
    WHEEL_ITEM_TOP = 6,  //特等獎
    
}

@ccclass('Wheel')
export class Wheel extends Component {

    private isOn :Boolean = false;
    private defineAngle : number = 28;
    //獎盤角度MAP
    private prizeAreaMap :Map<number, Vec2> = new Map<number, Vec2>();
    //獎勵概率
    private prizeProbability : Map<number, Vec2> = new Map<number, Vec2>();
    protected onLoad(): void {

        //初始化獎盤角度
        this.prizeAreaMap.set(1, new Vec2(0,60));
        this.prizeAreaMap.set(2, new Vec2(60,120));
        this.prizeAreaMap.set(3, new Vec2(120,180));
        this.prizeAreaMap.set(4, new Vec2(180,240));
        this.prizeAreaMap.set(5, new Vec2(240,300));
        this.prizeAreaMap.set(6, new Vec2(300,360));
        //初始化獎勵概率
        this.prizeProbability.set(1, new Vec2(0, 70));
        this.prizeProbability.set(2, new Vec2(70, 90));
        this.prizeProbability.set(3, new Vec2(90, 96));
        this.prizeProbability.set(4, new Vec2(90, 99));
        this.prizeProbability.set(5, new Vec2(99, 99.99));
        this.prizeProbability.set(6, new Vec2(99.99, 99.999));

    }

    getResult() {
        let randomVal = Math.random()*100;
        let result = 0;
               
    }

    onBtnWheel() {
        if(this.isOn) return;
        
        //設置默認角度
        this.node.angle = this.defineAngle;
        let rotateTime = Math.round(Math.random()*10) + 3;
        //cc.rotateto
        //cc.rotateBy(rotateTime, );
        this.isOn = true;
    }


    //Sthis.isOn = false;
}